let webpack = require('./node_modules/webpack/lib/webpack')

const CompressionPlugin = require("compression-webpack-plugin")

let proxyObj ={}

proxyObj['/api']={
    //websocket
    ws:false,
    //后端目标地址
    target:'http://localhost:9010/v1',
    //发送的请求头会设置target
    changeOrigin:true,
    //不重写请求地址
    pathRewrite:{
        '^/api':''
    }
}


module.exports = {
    productionSourceMap:false,
    devServer:{
        host:'localhost',
        port:8082,
        proxy:proxyObj
    },

    configureWebpack: {
        plugins: [
            new webpack.ProvidePlugin({
                $: "jquery",
                jQuery: "jquery",
                "windows.jQuery": "jquery"
            }),
            new CompressionPlugin({
                test: /\.(js|css)(\?.*)?$/i,//需要压缩的文件正则
                threshold: 10240,//文件大小大于这个值时启用压缩
                deleteOriginalAssets: false//压缩后保留原文件
            })

        ]
    },
    css: {
        loaderOptions: {
            css: {},
            postcss: {
                plugins: [
                    require('postcss-px2rem')({
                        remUnit: 60.5
                    })
                ]
            }
        }
    }

}


